<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script type="text/javascript" src="/Carrello/js/jquery-1.7.js"></script>
<script type="text/javascript">
$(document).ready(function(){
    
    $(document).on('click','#categoryData tr a', function() {
        if ($('#categoryData tr a').length < 2){
            $('#categoryData tr:last').remove();
        }else{
             var cell = $(this).parent("td");
             var row = $(cell).parent("tr").remove();
        }   
    });
    
    
    $('input:button').click(function(){
        if ($('#categoryData tr a').length < 1){
            $('#categoryData tr:last').after('<tr><td>Attribute name:</td><td><input name="aname" type="text" /></td><td>Attribute Type:</td><td><select name ="atype"><option>String</option><option>Integer</option><option>Double</option></select></td><td> Required: </td><td><input type="checkbox" name="required" value="checked" /><input type="hidden" name="required" value="1" /></td><td></td></tr>');
            $('#categoryData td:last').append($('<a id="removeLink" href="#" >Remove Attribute</a>'));
            
        }else{
            $('#categoryData tr:last').after('<tr><td>Attribute name:</td><td><input name="aname" type="text" /></td><td>Attribute Type:</td><td><select name ="atype"><option>String</option><option>Integer</option><option>Double</option></select></td><td> Required: </td><td><input type="checkbox" name="required" value="checked" /><input type="hidden" name="required" value="1" /></td><td></td></tr>');
            $('#categoryData td:last').append($('#removeLink').clone(true));
        }
    });
    
});
</script>
        
</script>
<#include "*/general/header.ftl">
</head>
<body>
	<h3>Add New Category</h3>
	<form action="addCategory.action" method="post">
		<table id="categoryData">
			<tr>
				<td>Select Parent Category:</td>
				<td><select name="pname"><#list parent as e>
						<option>${e.name}</option></#list>
				</select></td>
			</tr>
			<tr>
				<td>CategoryName:</td>
				<td><input name="categoryName" type="text" /></td>
			</tr>
			<tr>
				<td>Description:</td>
				<td><input name="description" type="text" /></td>
			</tr>
                        <tr>
                                <td> Inherit Parent Category Attributes ? </td>
                                <td><input type="checkbox" name="inherit" value="yes" /><input type="hidden" name="inherit" value="no" />
                        </tr>
			<tr>
				<td>Attribute name:</td>
				<td><input name="aname" type="text" /></td>
				<td>Attribute Type:</td>
				<td><select name = "atype">
                                       <option>String</option>
                                       <option>Integer</option>
                                       <option>Double</option>
                                </select>
                                </td>
                                <td> Required: </td>
                                <td><input type="checkbox" name="required" value="checked" /><input type="hidden" name="required" value="1" />
                                </td>
                                <td><a id="removeLink" href="#" >Remove Attribute</a>
                                </td>
			</tr>
                        
		</table>
		<input type="button"  value="Add New Attribute" />
                
		<input type="submit" value="Add Category"/>
	</form>

	<#include "*/general/footer.ftl">
</body>
</html>